<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_default
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>

<?php $_items = $this->getReviewsCollection()->getItems();?>
<?php if (count($_items)):?>
<div class="collateral-box dedicated-review-box" id="customer-reviews">
    <div class="head">
        <h4><?php echo $this->__('Customer Reviews') ?></h4>
    </div>

    <?php echo $this->getChildHtml('toolbar') ?>

    <ol style="margin-top:15px;">
        <?php $i=0; foreach ($_items as $_review): $i++;?>
            <?php if($i!=1):?>
            <div style="background:url(<?php echo $this->getSkinUrl('images/line.gif');?>) repeat-x; margin:5px 0; height:1px;"></div>
            <?php endif; ?>
            <li>
                <table class="ratings-list" cellspacing="0">
                    <tbody>
                        <?php foreach ($_review->getRatingVotes() as $_vote): ?>
                        <tr>
                            <td class="label"><strong><?php echo $_vote->getRatingCode() ?></strong></td>
                            <td>
                                <div class="rating-box">
                                    <div class="rating" style="width: <?php echo $_vote->getPercent() ?>%;"></div>
                                </div>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
                <div class="review-content">
				  <strong><?php echo $this->htmlEscape($_review->getTitle()) ?></strong><br/>
                  <?php echo $this->__('Reviewed by <strong>%s</strong>', $this->htmlEscape($_review->getNickname())) ?>
                  <span class="r_time"><?php echo $this->__('(Posted on %s)', $this->formatDate($_review->getCreatedAt()), 'long') ?></span>
                  <div class="replay-box">
                      <div class="replay-bottom">
                          <div class="replay-content">
                              <p class="r_content"><?php $detail = nl2br($this->htmlEscape($_review->getDetail())); if(strlen($detail)<150){echo $detail;}else{echo substr($detail,0 ,150),'<span id="reviewdot-',$i,'">...&nbsp;&nbsp;&nbsp;</span><span id="review-more-',$i,'" style="display:none">',substr($detail,150),'</span><a href="javascript:void(0);" onclick="reviewMore(',$i,')" id="review-txt-more-',$i,'">Read more</a>';} ?>
                                <a href="javascript:void(0);" style="display:none;" onclick="reviewLess('<?php echo $i?>');" id="review-txt-less-<?php echo $i;?>">&nbsp;&nbsp;&nbsp;Less</a>
                              </p>
                          </div>
                      </div>
                  </div>
                  
                  <?php if($_review->getReply()):?>
                        <div style="width:100%;height:20px;"></div>
                        Replied by <strong>HairExtensions Support</strong><span class="r_time"><?php echo $this->__('(Posted on %s)', $this->formatDate($_review->getReplyAt()), 'long') ?></span>
                        <div class="replay-box">
                            <div class="replay-bottom">
                                    <div class="replay-content r_content">
                                        <?php echo $_review->getReply() ?> 
                                    </div>
                            </div>
                        </div>
                  <?php endif;?>
                  
                <?php if ($_images = Mage::helper('reviewswithimg')->getReviewImages($_review)){?>
				<div style='padding-top:10px;padding-left:35px;'>
				<?php foreach($_images as $_image){?>
					<a style='display:block;float:left;margin-left:15px;width:90px;height:90px;' class='MagicZoomPlus' rel="disable-zoom:true;background-opacity:70;background-color:#FFFFFF;group:group_<?php echo $_review->getId()?>;" href="<?php echo $this->helper('review/image')->initImage($_image, 'image_no_water');?>">
						<img style="border:1px solid #dddddd;" src='<?php echo $this->helper('review/image')->initImage($_image, 'thumbnail')->resize(89, 89);?>' />
					</a>
				<?php }?>
				</div>
				<?php }?>
                </div>
                <div class="clear"></div>
            </li>
        <?php endforeach; ?>
    </ol>
<script type="text/javascript">
function reviewMore(i){
    document.getElementById('review-more-'+i).style.display = '';
    document.getElementById('reviewdot-'+i).style.display = 'none';
    document.getElementById('review-txt-more-'+i).style.display='none';
    document.getElementById('review-txt-less-'+i).style.display='';
}
function reviewLess(i){
    document.getElementById('review-more-'+i).style.display = 'none';
    document.getElementById('reviewdot-'+i).style.display = '';
    document.getElementById('review-txt-more-'+i).style.display='';
    document.getElementById('review-txt-less-'+i).style.display='none';
}
</script>
    <?php echo $this->getChildHtml('toolbar') ?>
</div>
<?php endif;?>

<br/>

<?php echo $this->getChildHtml('review_form') ?>
